﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Data.SqlServerCe;
using System.Windows;
using System.Windows.Input;

namespace BambolettaDB
{
    public class RequestVM: BaseVM
    {
        #region Properties and Fields
        private long _ID = -1;
        public long ID
        {
            get { return _ID; }
            set { _ID = value; NotifyPropertyChanged("ID"); }
        }

        private StringItemVM _Hair = new StringItemVM();
        public StringItemVM Hair
        {
            get { return _Hair; }
            set { _Hair = value; NotifyPropertyChanged("Hair"); }
        }

        private StringItemVM _Eye = new StringItemVM();
        public StringItemVM Eye
        {
            get { return _Eye; }
            set { _Eye = value; NotifyPropertyChanged("Eye"); }
        }

        private StringItemVM _Skin = new StringItemVM();
        public StringItemVM Skin
        {
            get { return _Skin; }
            set { _Skin = value; NotifyPropertyChanged("Skin"); }
        }

        private StringItemVM _Gender = new StringItemVM();
        public StringItemVM Gender
        {
            get { return _Gender; }
            set { _Gender = value; NotifyPropertyChanged("Gender"); }
        }

        private StringItemVM _Type = new StringItemVM();
        public StringItemVM Type
        {
            get { return _Type; }
            set { _Type = value; NotifyPropertyChanged("Type"); }
        }

        private StringItemVM _HairType = new StringItemVM();
        public StringItemVM HairType
        {
            get { return _HairType; }
            set { _HairType = value; NotifyPropertyChanged("HairType"); }
        }

        private string _Comment = "";
        public string Comment
        {
            get { return _Comment; }
            set { _Comment = value; NotifyPropertyChanged("Comment"); }
        }

        private CustomerVM _Customer = new CustomerVM();
        public CustomerVM Customer
        {
            get { return _Customer; }
            set { _Customer = value; NotifyPropertyChanged("Customer"); }
        }

        private DateTime _Date = DateTime.Now;
        public DateTime Date
        {
            get { return _Date; }
            set { _Date = value; NotifyPropertyChanged("Date"); }
        }
        #endregion

        #region Commands
        private DelegateCommand _EditCommand;
        public ICommand EditCommand
        {
            get { return _EditCommand; }
        }
        public void EditExecuted(object parameter)
        {
            AddRequestDialog dlg = new AddRequestDialog(this);
            dlg.Owner = Application.Current.MainWindow;
            dlg.ShowDialog();
        }

        private DelegateCommand _DeleteCommand;
        public ICommand DeleteCommand
        {
            get { return _DeleteCommand; }
        }
        public void DeleteExecuted(object parameter)
        {
            DBCommands.DeleteRequest(this);
            MainVM main = MainVM.GetInstance();
            if (main != null)
            {
                main.Requests.Remove(this);
            }
        }
        #endregion

        #region Constructor
        public RequestVM()
        {
            _EditCommand = new DelegateCommand(new Action<object>(EditExecuted));
            _DeleteCommand = new DelegateCommand(new Action<object>(DeleteExecuted));
        }
        #endregion

        #region Public methods
        public void Copy(RequestVM from)
        {
            Customer.Copy(from.Customer);
            Comment = from.Comment;
            Date = from.Date;
            Hair = from.Hair;
            Eye = from.Eye;
            Gender = from.Gender;
            Skin = from.Skin;
            ID = from.ID;
            Type = from.Type;
            HairType = from.HairType;
        }

        #endregion
    }
}
